package dataModifiers;

import java.util.List;

import inputs.Input;

/**
 * Average Modifier class
 * Extends Modifier functionality
 * 
 * Outputs the average of all the given inputs.
 * 
 * @author Dylan James
 *
 */
public class Average extends Modifier{
	private int total, count;
	
	public Average(List<Input> inputs)
	{
		super(inputs);
	}
	
	@Override
	protected void Initialize() {
		total = 0;
		count = 0;
	}

	@Override
	protected void AccountForInputs() {
		int minTotal = 0;
		int maxTotal = 0;
		int count = 0;
		
		for(Input input : inputs)
		{
			minTotal += input.getMin();
			maxTotal += input.getMax();
			count++;
		}

		this.min = minTotal / count;
		this.max = maxTotal / count;
	}

	@Override
	protected void Update() {
		
		if (!getRun())
		{
			total = 0;
			count = 0;
		}		
		
		for (Input input : inputs)
		{
			total += input.getValue();
			count++;
		}

		this.value = total / count;

	}


}
